/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.inspur.edp.metadata.service.dev.core.entity.validate;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.inspur.edp.lcm.metadata.spi.entity.ValidationLevelEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * 元数据关系校验结果详情
 *
 * @author sunhongfei
 */
@Setter
@Getter
public class MetadataValidateFailureDetail {
    // 校验结果详细信息
    private String msg;

    // 校验结果级别
    @JsonIgnore
    private ValidationLevelEnum level;

    public MetadataValidateFailureDetail(String msg, ValidationLevelEnum level) {
        this.msg = msg;
        this.level = level;
    }

    public static MetadataValidateFailureDetail error(String msg) {
        return new MetadataValidateFailureDetail(msg, ValidationLevelEnum.ERROR);
    }

    @JsonIgnore
    public boolean isError() {
        return this.level == ValidationLevelEnum.ERROR;
    }
}
